<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Exercicio 04 - JSP</title>
</head>
<body>
	<h1>Formulário:</h1>

	<%
		String nome = request.getParameter("nome");
		String idade = request.getParameter("idade");
		String rg = request.getParameter("rg");
		if (nome == null && idade == null && rg == null) {
	%>

	<form action="#">
		<table>
			<tr>
				<td>Nome:</td>
				<td><input type="text" name="nome"></td>
			</tr>
			<tr>
				<td>Idade:</td>
				<td><input type="text" name="idade"></td>
			</tr>
			<tr>
				<td>Rg:</td>
				<td><input type="text" name="rg"></td>
			</tr>
			<tr>
				<td><input type="submit" value="Enviar"></td>
			</tr>
		</table>
	</form>
	<%
		} else {
	%>
	<form>
		<table>
			<tr>
				<input type="hidden" name="nome_hidden" value="<%=nome%>">
				<td>Nome:</td>
				<td><%=nome%></td>
			</tr>
			<tr>
				<input type="hidden" name="idade_hidden" value="<%=idade%>">
				<td>Idade:</td>
				<td><%=idade%></td>
			</tr>
			<tr>
				<input type="hidden" name="rg_hidden" value="<%=rg%>">
				<td>Rg:</td>
				<td><%=rg%></td>
			</tr>
			<tr>
				<td><input type="submit" value="Confirmar"></td>
			</tr>
		</table>
	</form>
	<%
		}
	%>
</body>
</html>